package cn.wolfcode.wolf2w.web.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Region;
import cn.wolfcode.wolf2w.query.DestinationQuery;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping ("destinations")  //为什么这里不用加/?
public class DestinationController {
    @Autowired
    private IDestinationService destinationService ;
    @Autowired
    private IRegionService regionService ;
    @GetMapping("hotRegion")
    public Object hotRegion(){
        List<Region> regions = regionService.hotRegion();
        return  JsonResult.success(regions);
    }
    //
    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> destinations = destinationService.getDestByRegionIdForApi(regionId);
        return  JsonResult.success(destinations);
    }

}
